#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;


//高精度加法

/*
void solve2() {

	int n;
	cin >> n;
	ll ans = 0;
	ll temp = 1;
	for (int i = 1; i <= n; ++i) {
		temp *= i;
		ans += temp;
	}
	cout << ans;
	return;
}
*/

string GJD_JF(string a, string b) {
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	string result="";
	int i = 0;
	int carry = 0;
	while (i < a.size() || i < b.size() || carry) {
		int trp1 = i < a.size() ? a[i] - '0' : 0;
		int trp2 = i < b.size() ? b[i] - '0' : 0;
		
		int temp = (trp1 + trp2 + carry) % 10;
		
		result.push_back(temp + '0');

		carry = (trp1 + trp2 + carry) / 10;
		++i;
	}
	reverse(result.begin(), result.end());
	//cout << "result:" << result;
	return result;
}

//高精度乘法
string GJD_CF(string a, string b) {
	if (a == "0" || b == "0") {
		return "0";
	}
	//反转字符串,从小位相乘
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());


	vector<int> result(a.size() + b.size(), 0);
	//诸位相乘
	for (int i = 0; i < a.size(); ++i) {
		for (int j = 0; j < b.size(); ++j) {
			int digiA = a[i] - '0';
			int digiB = b[j] - '0';
			result[i + j] = result[i + j] + digiA * digiB;
			result[i + j + 1] = result[i + j + 1] + result[i + j] / 10;
			result[i + j] %= 10;

		}
	}
	while (result.back() == 0) {
		result.pop_back();
	}
	string res;
	for (int i = result.size() - 1; i >= 0; --i) {
		res.push_back(result[i] + '0');
	}
	//cout << "res:" << res;
	return res;
}

void solve3() {
	int n;
	cin >> n;
	string  ans = "0";
	string temp = "1";
	for (int i = 1; i <= n; ++i) {
		temp = GJD_CF(temp, to_string(i));
		ans = GJD_JF(ans, temp);
		
	}
	cout << ans;
	return;
}
const int N = 1e6 + 10;
vector<string> a;
string a1;
void solve4() {
	int n;
	int x;
	int ans = 0;
	cin >> n >> x;
	for (int i = 1; i <= n; ++i) {
		a1 = to_string(i);
		for (int j = 0; j < a1.size(); ++j) {
			if (a1[j] == (x+'0'))
				ans++;
		}
	}
	cout << ans;
	return;
}

int main() {
	//solve1();
	//solve2();
	//GJD_JF("12345678901234567890","98765432109876543210");
	//GJD_CF("1234567890", "987654321");
	//cout << endl;
	//GJD_CF("123", "9876");
	/*string s1, s2;
	cin >> s1 >> s2;
	cout<<GJD_CF(s1, s2);*/
	//solve3();
	solve4();
	return 0;
}

